﻿@{
    ViewBag.Title = "Template/Index";
}


<div data-bind="template: {name:'data-template',foreach:datas,as:'t'}"></div>

<script type="text/html" id="data-template">
    <div data-bind="text: name"></div>
    <div data-bind="template: {name:'value-template',foreach:value}" style="padding-left: 20px;"></div>
</script>

<script type="text/html" id="value-template">
    <div data-bind="text:$data"></div>
</script>

<script type="text/javascript">
    $(function () {
        var viewMode = {
            datas: ko.observableArray([{ name: "张三", value: [1, 2, 3, 4] }, { name: "李四", value: [4, 5, 6] }])
        };

        ko.applyBindings(viewMode);
    });
</script>
